<?php
class Common
{
	private $_db;
	
	/**
	 * Delcampe_Stats::__construct()
	 * 
	 * @return void
	 */
	public function __construct() 
  	{ 
  		$this->_db = Zend_Registry::get('db'); 
  	}
  	
	private function listCountries()
	{
		$options = $this->_db->fetchAll("
				SELECT country_id, country_name
				FROM countries
		");

		return $options;
	}
	
    private function listCities()
	{
		$sql="SELECT city_id, city_name 
		      FROM cities";
		$options = $this->_db->fetchPairs($sql);

		return $options;
	}
	
	public function getCountries()
	{
		$options = $this->_db->fetchAll("
				SELECT country_id, country_name
				FROM countries
		");

		return $options;
	}

	public function getCity($country)
	{
		$sql="SELECT city_id, city_name FROM cities where country_id = " . $country;
		//echo $sql;exit;
		$options = $this->_db->fetchAll($sql);

		return $options;
	}
	
	public function getHotelbyCity($city)
	{
		$sql="SELECT hotel_id, hotel_title FROM hotels where hotel_city = " . $city;
		//echo $sql;exit;
		$options = $this->_db->fetchAll($sql);

		return $options;
	}
	
    public function getHotelbyCountry($country)
	{
		$sql="SELECT hotel_id,hotel_title FROM hotels where hotel_country=".$country."";
		//echo $sql;exit;
		$options = $this->_db->fetchAll($sql);

		return $options;
	}
    
	public function getCities() {
        $options = $this->listCities();
        return $options;
    }
    
    /**
     * get the default country list
     *
     * @return array
     */
    
    public function getDefaultCountryList() 
    {
    	$country_arr = $this->_db->fetchAll("
    		SELECT * FROM allcountry
    	");
    	
    	return $country_arr;
    }
    
    
} 
?>